﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Wizard.UI;
using Wizard.Controls;

namespace RoketPack.Configuration
{
    public partial class ProtocolAssociationPage : InternalWizardPage
    {
        public ProtocolAssociationPage()
        {
            InitializeComponent();
        }

        private void ProtocolAssociationPage_SetActive(object sender, CancelEventArgs e)
        {
            this.SetWizardButtons(WizardButtons.Next);

            if (Protocol.IsAssociated())
            {
                this.SetUACRequired(false);
                this.c_UACWarningLabel.Text = @"RoketPack is already associated   
with the roket: protocol.";
            }
            else if (UAC.IsAdmin())
            {
                this.SetUACRequired(false);
                this.c_UACWarningLabel.Text = @"No privilege elevation is required
to associate this protocol.";
            }
            else
            {
                this.SetUACRequired(true);
                this.c_UACWarningLabel.Text = @"You will be prompted by User
Account Control to associate
this protocol.";
            }
        }

        private void ProtocolAssociationPage_WizardNext(object sender, WizardPageEventArgs e)
        {
            if (Protocol.IsAssociated())
                return;

            if (!Protocol.EnsureAssociation())
            {
                e.NewPage = "ProtocolAssociationPage";
                this.c_UACWarningLabel.Text = @"Unable to successfully associate  
RoketPack with the protocol.";
            }
        }
    }
}
